package com.wteam.dragon.model.pojo.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.wteam.dragon.system.basebean.bean.BaseBean;
import lombok.Data;

import java.util.Objects;

/**
 * 部门
 * @Author 陈晓辉
 * @Date 2020/3/23
 */

@Data
@Table
@TableName
public class Dept extends BaseBean {
    @IsKey
    @IsNotNull
    @IsAutoIncrement
    @TableId(type = IdType.AUTO)
    @ColumnType(MySqlTypeConstant.BIGINT)
    @Column(comment = "自增id")
    private Long id;

    @IsNotNull
    @ColumnType(MySqlTypeConstant.VARCHAR)
    @Column(comment = "部门名")
    private String name;

    @IsNotNull
    @DefaultValue("1")
    @ColumnType(MySqlTypeConstant.TINYINT)
    @Column(comment = "是否禁用")
    private Boolean enabled;

    @IsNotNull
    @DefaultValue("0")
    @ColumnType(MySqlTypeConstant.BIGINT)
    @Column(comment = "上级部门id，没有则为0")
    private Long pid;

    @IsNotNull
    @DefaultValue("99999")
    @ColumnType(MySqlTypeConstant.BIGINT)
    @Column(comment = "排序")
    private Long sort;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Dept dept = (Dept) o;
        return Objects.equals(id, dept.id) &&
                Objects.equals(name, dept.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }
}